<?php
/*
 * Test sniff with long arrays.
 */

$bad = array( 'key' => 'value' ); // OK, one item single-line associative arrays are ok.

// Test for fixing nested associative arrays.
$bad = array( array( 'key1' => 'value1', 'key2' => array('sub1' => 1, 'sub2' => 2) ), $key3 => 'value3', array( 'value4', 10 => 'value5', ) ); // Bad.

// Test for fixing mixed single & multi-line nested associative arrays.
$bad = array(
	array( 'key1' => 'value1', array('sub1' => 1,'sub2' => 2,)),
	$key3 => 'value3',
	array( 'value4', 10 => 'value5' )
); // Bad.

// Test for fixing associative arrays with multiple values & line indented with whitespace.
		$bad = array( 'key1' => 'value1', 'key2' => 'value2', $key3 => 'value3', 'value4', 10 => 'value5' ); // Bad.

// Test for fixing associative arrays with comments between values.
$bad = array( 'key1' => 'value1', /* comment */ 'key2' => 'value2' ); // Bad.

// Test for fixing non-associative array with a nested associative array which *will* be fixed.
$bad = array( 'value1', 'value2', array( 'sub1' => 1, 'sub2' => 2 ), 'value4' ); // Bad.

/*
 * Tests for multi-line arrays - array items each on new line.
 */
// OK.
$value = array(
	1,
	2, /* Comment. */
	3,
);

$value = array(
	1 => $one,
	2 => $two, // phpcs:ignore Standard.Category.Sniff.Errorcode -- for reason.
	3 => $three, // Comment.
);

// Bad.
$value = array(1,
	2 ,     3 ,
);

$value = array(1 => $one,
	2 => $two , /* Comment. */ 3 => $three , );

$value = array(
	 '1'=> TRUE, FALSE,     '3' => 'aaa',);

$x = array('name' => 'test',
	 );

$foo = array(1
, 2);

// phpcs:set WordPress.Arrays.ArrayDeclarationSpacing allow_single_item_single_line_associative_arrays false

$bad = array( 'key' => 'value' ); // Bad.
$bad = array( 'key1' => 'value1', 'key2' => 'value2' ); // Bad.

// phpcs:set WordPress.Arrays.ArrayDeclarationSpacing allow_single_item_single_line_associative_arrays true

$foo = array(
	'meta_key'   => 'foo', // phpcs:ignore Standard.Category.SniffName.ErrorCode
	'meta_value' => 'bar', // phpcs:ignore Standard.Category.SniffName.ErrorCode
);

// Test for fixing array with multi-line comments between values.
$bad = array(
	'key1' => 'value1', /* comment
	end */ 'key2' => 'value2', // Bad.
	/* Non-trailing comment. */
	'key3' => 'value3', /* comment
	end */
	'key4' => 'value4'
);

// Don't confuse list arrows with array arrows.
$okay = array( $item1, list( 'key1' => $a, 'key2' => $b ) = $array, $item3 );

// Live coding/parse error.
// This must be the last test in the file!
$ignore = array( $item1, 'key' => 'value',
